package com.dt76.smallloanbackenduser.controller.zjs;

import com.dt76.smallloanbackenduser.remote.zjs.PowerRemote;
import com.dt76.smallloanbackenduser.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;


@Controller
@RequestMapping("/zjs")
public class PowerController {

    @Autowired
    private PowerRemote powerRemote;

    @RequestMapping("/qryPagePowerAll")

    public String qryPageAllPowerUser(Model model,
                                      @RequestParam(defaultValue = "1")Integer currentPageNo,
                                      @RequestParam(value = "qryTime",required = false)String qryTime,
                                      @RequestParam(value = "qryNum",required = false)String qryNum,
                                      @RequestParam(value = "qryMoney",required = false)String qryMoney,
                                      @RequestParam(value = "qryType",required = false)String qryType,
                                    @RequestParam(value = "qryRank",required = false)String qryRank,
                                      @RequestParam(value = "qryLebal",required = false)String qryLebal
                                     ) {



        if (currentPageNo<=0){
            currentPageNo=1;
        }

        if(qryNum == null || qryNum.equals("")){qryNum = "0" ;}
        if(qryMoney == null || qryMoney.equals("")){qryMoney = "0";}
        if(qryTime == null || qryTime.equals("")){qryTime = "0";}
        if(qryType == null || qryType.equals("")){qryType = "0";}
        if(qryLebal == null || qryLebal.equals("")){qryLebal = "0";}
        if(qryRank == null || qryRank.equals("")){qryRank = "0";}


        System.out.println("qryTime:"+qryTime);
        System.out.println("qryNum:"+qryNum);
        System.out.println("qryMoney:"+qryMoney);
        System.out.println("qryType:"+qryType);
        System.out.println("qryLebal:"+qryLebal);
        System.out.println("qryLebal:"+qryRank);

        Page page = powerRemote.qryPageAllPowerUser(currentPageNo,Integer.valueOf(qryTime),Integer.valueOf(qryNum),Integer.valueOf(qryMoney),Integer.valueOf(qryType),Integer.valueOf(qryRank),Integer.valueOf(qryLebal));

        //03.组织返回值

        model.addAttribute("querypowerUserList", page.getRows());//用户列表
        model.addAttribute("page", page);
        //加入动态查询条件返回
        model.addAttribute("qryNum", qryNum);
        model.addAttribute("qryMoney", qryMoney);
        model.addAttribute("qryTime", qryTime);
        model.addAttribute("qryType", qryType);
        model.addAttribute("qryLebal", qryLebal);
        model.addAttribute("qryRank", qryRank);

        System.out.println("page.getRows():"+page.getRows());
        System.out.println(page);
        return "pages/zjs/borrowingPower";
    }



}
